<extend name="work/base"/>
<block name="content">

    <div class="layui-tab layui-tab-brief" lay-filter="projecttab">
        <ul class="layui-tab-title">
            <li class="layui-this"  lay-id="1">项目概况</li>
            <li lay-id="2">缺陷管理</li>
            <li lay-id="3">缺陷管理</li>
            <li lay-id="4">项目文档</li>
            <li lay-id="5">项目日志</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                项目概况
            </div>
            <div class="layui-tab-item">
                <form class="layui-form inline-form">
                    <div class="pull-left">
                        <div class="layui-inline dropdown">
                            <select name="bugstatus" lay-search lay-filter="status">
                                <option value="">选择缺陷状态</option>
                                <volist name="bug_status" id="vo" key="k">
                                    <option value="{$k}"> {$vo}</option>
                                </volist>
                            </select>
                        </div>
                        <div class="layui-inline dropdown">
                            <input name="title" class="layui-input" type="text" id="bugtitle" placeholder="项目名称">
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn  layui-btn-normal" lay-submit lay-filter="search_btn"><i
                                    class="layui-icon">&#xe615;</i>搜索
                            </button>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn layui-btn-normal  ajax-form" data-url="{:url('bugadd?id='.input('id'))}"><i
                                    class="layui-icon">&#xe61f;</i> 新增
                            </button>
                        </div>
                    </div>
                </form>
                <table class="layui-table text-center" id="list" lay-filter="list" list-url="{:url('buglists')}"
                       edit-url="{:url('editform')}" assigned-url="{:url('editcategory')}" del-url="{:url('delete')}"
                       delinfo-url="{:url('delete')}"></table>

            </div>
            <div class="layui-tab-item">
                <form class="layui-form inline-form">
                    <div class="pull-left">
                        <div class="layui-inline dropdown">
                            <select name="bugdstatus" lay-search lay-filter="bugstatus">
                                <option value="">选择缺陷状态</option>
                                <volist name="bug_status" id="vo" key="k">
                                    <option value="{$k}"> {$vo}</option>
                                </volist>
                            </select>
                        </div>
                        <div class="layui-inline dropdown">
                            <input name="title" class="layui-input" type="text" id="bugtitle" placeholder="缺陷名称">
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn  layui-btn-normal" lay-submit lay-filter="bugsearch_btn"><i
                                    class="layui-icon">&#xe615;</i>搜索
                            </button>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn layui-btn-normal  ajax-form-bug" data-url="{:url('project/bugadmin/bugadd?id='.input('id'))}"><i
                                    class="layui-icon">&#xe61f;</i> 新增
                            </button>
                        </div>
                    </div>
                </form>
                <table class="layui-table text-center" id="buglist" lay-filter="buglist" list-url="{:url('project/bugadmin/buglists')}"
                       edit-url="{:url('bugeditform')}" assigned-url="{:url('bugeditcategory')}" del-url="{:url('bugdelete')}"
                       delinfo-url="{:url('bugdelete')}"></table>
            </div>
            <div class="layui-tab-item">
                项目文档


            </div>
            <div class="layui-tab-item">
                项目日志

            </div>
        </div>
    </div>


</block>

<block name="script">
    <script type="text/html" id="barDemo">
        <a class="layui-btn  layui-btn-xs" lay-event="applyinfo" info_id="{:url('bugwork')}"><i class="fa fa-laptop"></i>处理</a>
        <a class="layui-btn  layui-btn-xs " lay-event="edit"><i class="fa fa-pencil"></i> 编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete"> <i class="fa fa-trash-o"></i> 删除</a>
    </script>

    <script type="text/javascript">
        layui.use(['element', 'table', 'form'], function () {
            var table = layui.table
                , element = layui.element
                , form = layui.form;
            element.on('tab(projecttab)', function(){
                console.log(this.getAttribute('lay-id'));
                if (this.getAttribute('lay-id') == 1) {
                    getbuginfo()
                }
                if (this.getAttribute('lay-id') == 2) {

                    table.render({
                        elem: '#list'
                        , url: "{:Url('buglists')}"
                        , toolbar: '<div></div>'
                        , page: true
                        , loading: true
                        ,limit:20
                        , defaultToolbar: ['filter', 'print', 'exports']
                        , cols: [[
                             {field: 'level_id', width: 90, title: '缺陷等级'}
                            , {field: 'title', title: '缺陷名称', edit: 'text'}
                            , {field: 'uidnickname', width: 120, title: '发布人'}
                            , {field: 'touidnickname', width: 120, title: '完成人员'}
                            , {field: 's_time', width: 100, title: '开始时间'}
                            , {field: 'e_time', width: 100, title: '结束时间'}
                            , {field: 'p_time', width: 115, title: '计划用时(分钟)', edit: 'text'}
                            , {field: 'w_time', width: 115, title: '实际用时(分钟)', edit: 'text'}
                            , {field: 'status', width: 100, title: '缺陷状态', edit: 'text'}
                            , {fixed: 'right', width: 220, title: '操作', toolbar: '#barDemo'}
                        ]]
                    });
                }
                if (this.getAttribute('lay-id') == 3) {
                    table.render({
                        elem: '#buglist'
                        , url: "{:Url('project/bugadmin/buglists')}"
                        , toolbar: '<div></div>'
                        , page: true
                        , loading: true
                        ,limit:20
                        , defaultToolbar: ['filter', 'print', 'exports']
                        , cols: [[
                             {field: 'level_id', width: 90, title: '缺陷等级'}
                            , {field: 'title', title: '缺陷名称', edit: 'text'}
                            , {field: 'uidnickname', width: 120, title: '发布人'}
                            , {field: 'touidnickname', width: 120, title: '完成人员'}
                            , {field: 's_time', width: 100, title: '开始时间'}
                            , {field: 'e_time', width: 100, title: '结束时间'}
                            , {field: 'p_time', width: 115, title: '计划用时(分钟)', edit: 'text'}
                            , {field: 'w_time', width: 115, title: '实际用时(分钟)', edit: 'text'}
                            , {field: 'status', width: 100, title: '缺陷状态', edit: 'text'}
                            , {fixed: 'right', width: 220, title: '操作', toolbar: '#barDemo'}
                        ]]
                    });
                }
            });
            form.on('submit(bugsearch_btn)', function (data) {
                table.reload('list', {
                    url: "{:Url('project/bugadmin/buglists')}"
                    , page: {
                        curr: 1
                    }
                    , where: data.field
                });
                return false;
            });
            form.on('select(bugstatus)', function (data) {
                table.reload('list', {
                    url: "{:Url('project/bugadmin/buglists')}"
                    , page: {
                        curr: 1
                    }
                    , where: {
                        status: data.value
                    }
                });
                return false;
            });
            form.on('submit(search_btn)', function (data) {
                table.reload('list', {
                    url: "{:Url('buglists')}"
                    , page: {
                        curr: 1
                    }
                    , where: data.field
                });
                return false;
            });
            form.on('select(status)', function (data) {
                table.reload('list', {
                    url: "{:Url('buglists')}"
                    , page: {
                        curr: 1
                    }
                    , where: {
                        status: data.value
                    }
                });
                return false;
            });
        });
    </script>
</block>
